<template>
  <div>
    <h1>添加学生</h1>
    <p>姓名：<input type="text" v-model="form.name"></p>
    <p>年龄：<input type="text" v-model="form.age"></p>
    <button @click="join">提交</button>
    <router-link :to="{name:'stu_show'}">查看自己的学生</router-link>
    <router-link :to="{name:'stu_show2'}">查看别的学生</router-link>
  </div>
</template>

<script>
export default {
  name: "stu_add",
  data() {
    return {
      form: {'tea': localStorage.getItem('userid')}
    }
  },
  methods: {
    join() {
      this.$axios.post('users/stu/', this.form)
        .then(res => {
          if (res.data.code == 200) {
            alert('添加成功')

          } else {
            alert('添加失败')
          }
        })
    }
  }

}
</script>

<style scoped>

</style>
